home *** CD-ROM | disk | FTP | other *** search
- Path: netnews1.apci.com!usenet
- From: wardmw@apci.com (Martin Ward)
- Newsgroups: comp.lang.c
- Subject: Re: Keyboard input: C's equivalent to BASIC's Inkey$
- Date: Thu, 25 Jan 1996 13:50:09 GMT
- Organization: Air Products Europe
- Message-ID: <4e822q$fls@netnews1.apci.com>
- References: <Pine.SUN.3.91.960111212844.17033A@suntan>
- Reply-To: wardmw@apci.com
- NNTP-Posting-Host: p1862.apci.com
- X-Newsreader: Forte Free Agent 1.0.82
-
- The following will work for DOS:
-
- >DO
- > DO WHILE k$ = "" 'As long as there is no key, keep waiting
- > k$=Inkey$
- > ' Additional statements to increment a counter, update and display a
- > ' clock with running seconds, etc, can go here.
- > LOOP
- > PRINT k$; 'Print the key that was just gotten
- > k$=""
- >LOOP
-
- while (TRUE)
- {
- while (! kbhit() ) /* Returns FALSE if no key pressed */
- {
- /* Do something else here */
- }
- k = getch(); /* Get the key that was pressed */
- printf("%c\n", k);
- }
-
- HTH
-
- |\/|
-
-